//
// Created by wze-zero on 2024/10/21.
//
#include <iostream>

using namespace std;

void check(const int arr[], int n, int sum, int &start, int &end) {
    int temp, sub = 99999;
    for (int i = 0; i < n; ++i) {
        temp = 0;
        for (int j = 0; j < n - i; ++j) {
            temp += arr[i + j];
            if (abs(sum - temp) < sub) {
                sub = abs(sum - temp);
                start = i;
                end = i + j;
            }
        }
    }
}

int main() {
    int n, m, num, sum = 0, start = -1, end = -1;
    cin >> n >> m;
    int arr[m];
    for (int i = 0; i < n; ++i) {
        cin >> num;
        sum += num;
    }
    for (int i = 0; i < m; ++i) {
        cin >> arr[i];
    }
    check(arr, m, sum, start, end);
    for (int i = start; i <= end; ++i) {
        cout << arr[i] << ' ';
    }
    return 0;
}